package com.scwatch.ext.domain;

import com.scwatch.core.domain.Site;
import com.scwatch.core.domain.User;
import com.scwatch.core.support.Siteable;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * Advertisement 悬浮层广告
 *
 * @author gjl
 *
 */
@Entity
@Table(name = "cms_advertisement")
public class Advertisement implements java.io.Serializable,Siteable {
    private static final long serialVersionUID = 1L;


    private Integer id;

    /**
     * 广告图片地址
     */
    private String image;

    /**
     * 跳转链接
     */
    private String contentUrl;

    /**
     * 显示次数（0表示每次启动都显示）
     */
    private Integer showCount;

    /**
     * 显示时间/秒（0表示只能用户手动关闭）
     */
    private Integer showTime;

    /**
     * 数据版本
     */
    private Integer versionCode;

    /**
     * 创建日期
     */
    private Date createDate;

    /**
     * 更新日期
     */
    private Date udpateDate;

    /**
     * 站点
     */
    private Site site;

    /**
     * 用户
     */
    private User user;

    /**
     * 是否发布 1，发布 2不发布
     */
    private String publish;

    private String relateNews;   //f_relate_news 关联新闻

    private Integer adPosition;

    private Integer adType;

    private String productCode;

    @Transient
    private List<String> newsUrl;   //f_relate_news 关联新闻


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "f_user_id")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "f_site_id", nullable = false)
    public Site getSite() {
        return site;
    }

    public void setSite(Site site) {
        this.site = site;
    }

    @Id
    @Column(name = "f_adv_id", unique = true, nullable = false)
    @TableGenerator(name = "tg_cms_advertisement", pkColumnValue = "cms_advertisement", initialValue = 1, allocationSize = 10)
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "tg_cms_advertisement")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "f_image", length =500)
    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }


    @Column(name = "f_content_url", length =500)
    public String getContentUrl() {
        return contentUrl;
    }

    public void setContentUrl(String contentUrl) {
        this.contentUrl = contentUrl;
    }

    @Column(name = "f_show_count")
    public Integer getShowCount() {
        return showCount;
    }

    public void setShowCount(Integer showCount) {
        this.showCount = showCount;
    }

    @Column(name = "f_show_time")
    public Integer getShowTime() {
        return showTime;
    }

    public void setShowTime(Integer showTime) {
        this.showTime = showTime;
    }

    @Column(name = "f_version_code")
    public Integer getVersionCode() {
        return versionCode;
    }

    public void setVersionCode(Integer versionCode) {
        this.versionCode = versionCode;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "f_creation_date", nullable = false)
    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "f_update_date")
    public Date getUdpateDate() {
        return udpateDate;
    }

    public void setUdpateDate(Date udpateDate) {
        this.udpateDate = udpateDate;
    }

    @Column(name = "f_is_publish", length =2)
    public String getPublish() {
        return publish;
    }
    public void setPublish(String publish) {
        this.publish = publish;
    }

    @Column(name = "f_relate_news", length = 1000)
    public String getRelateNews() {
        return relateNews;
    }

    public void setRelateNews(String relateNews) {
        this.relateNews = relateNews;
    }

    @Column(name = "f_position")
    public Integer getAdPosition() {
        return adPosition;
    }

    public void setAdPosition(Integer adPosition) {
        this.adPosition = adPosition;
    }
    @Column(name = "f_ad_type")
    public Integer getAdType() {
        return adType;
    }

    public void setAdType(Integer adType) {
        this.adType = adType;
    }
    @Column(name = "f_product_code")
    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    @Transient
    public List<String> getNewsUrl() {
        return newsUrl;
    }
    @Transient
    public void setNewsUrl(List<String>  newsUrl) {
        this.newsUrl = newsUrl;
    }

    @Transient
    private String productType;
    @Transient
    private String productUrl;
    @Transient
    private String productJson;
    @Transient
    public String getProductType() {
        return productType;
    }
    @Transient
    public void setProductType(String productType) {
        this.productType = productType;
    }
    @Transient
    public String getProductUrl() {
        return productUrl;
    }
    @Transient
    public void setProductUrl(String productUrl) {
        this.productUrl = productUrl;
    }
    @Transient
    public String getProductJson() {
        return productJson;
    }

    public void setProductJson(String productJson) {
        this.productJson = productJson;
    }
}
